package team.seekers.hula.course.structure.section.entity.dao;

import com.baomidou.mybatisplus.annotation.*;
import lombok.*;
import org.springframework.beans.BeanUtils;
import team.seekers.hula.common.entity.BaseDO;
import team.seekers.hula.course.structure.section.entity.dto.SectionProcessDTO;

import java.util.Date;

/**
 * (EduSectionContentProcess)实体类
 *
 * @author GH
 * @since 2022-04-30 18:07:15
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(SectionProgressDOField.TABLE_NAME)
public class SectionProgressDO extends BaseDO {

    private static final long serialVersionUID = 1L;

    @TableId(value = SectionProgressDOField.ID, type = IdType.ASSIGN_ID)
    private String id;
    /**
     * 用户id
     */
    @TableField(SectionProgressDOField.USER_ID)
    private String userId;
    /**
     * 章节内容id
     */
    @TableField(SectionProgressDOField.SECTION_ID)
    private String sectionId;
    /**
     * 视频/文档进度百分比（取整）
     */
    @TableField(SectionProgressDOField.PROGRESS)
    private Integer progress;

    @TableField(SectionProgressDOField.DELETED)
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(value = SectionProgressDOField.GMT_CREATE, fill = FieldFill.INSERT)
    private Date gmtCreate;

    @TableField(value = SectionProgressDOField.GMT_MODIFIED, fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;


    public static SectionProgressDO fromDTO(SectionProcessDTO contentProcessDTO){
        SectionProgressDO sectionProgressDO = new SectionProgressDO();
        BeanUtils.copyProperties(contentProcessDTO, sectionProgressDO);
        return sectionProgressDO;
    }
}
